home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Who's dumb: Summary
- Date: Sat, 17 Feb 96 23:06:59 GMT
- Organization: none
- Message-ID: <824598419snz@genesis.demon.co.uk>
- References: <4fv61e$mho@micky.ibh-dd.de>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4fv61e$mho@micky.ibh-dd.de> beck@duck.ibh-dd.de "Andre Beck" writes:
-
- >Hi,
- >
- >thanks to all who replied to me regarding my problem
- >
- > x = (*dat++ << 8) | *dat++;
- >
- >It turns out to be _ME_ who is dumb in the given case, because I
- >didn't know about the subtle issue of sequence points in C. The
- >above expression has two evaluations with side effects in one line,
-
- That isn't in itself wrong. The problem is that the same variable/object
- (in this case dat) is being modified more than once between sequence points.
- The following for example is legal:
-
- x = (*p1++ << 8) | *p2++;
-
- For a more interesting case consider:
-
- x = ((*p1)++ << 8) | (*p2)++;
-
- This is legal only if p1 and p2 point to different objects. So the problem
- of determining whether this is legal or not can't always be resolved at
- compile time.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-